package org.hackystat.devcathlon.ui.page.scoreboard.gameinfopanel;

import java.util.ArrayList;
import java.util.List;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.panel.Panel;
import org.hackystat.devcathlon.engine.match.Match;
import org.hackystat.devcathlon.engine.team.Team;
import org.hackystat.devcathlon.ui.DevcathlonSession;
import org.hackystat.devcathlon.ui.page.matches.MatchesSession;

/**
 * The panel is a holder for team images and score.
 *  
 * @author Daniel Arakaki
 *
 */
public class GameInfoPanel extends Panel {
  
  /** Support serialization. */
  private static final long serialVersionUID = 1L;

  /**
   * Initialize sessions, add elements to Game Information panel. 
   * 
   * @param id The Wicket id from the scoreboard page.
   * @param match A clicked match from the Scores panel.
   */
  public GameInfoPanel(String id, Match match) {
    super(id);
    DevcathlonSession devcathlonSession = DevcathlonSession.get();
    MatchesSession matchesSession = devcathlonSession.getMatchesSession();
    
    List<Team> teamList = new ArrayList<Team>(match.getTeams());
    
    add(new Label("matchNameHeader", matchesSession.getMatch(match.getName()).getName()));
    add(new Label("teamOneName", teamList.get(0).getName()));
    add(new Label("scoreOne", 
        matchesSession.getMatch(match.getName()).getTeamPoints(teamList.get(0)).toString()));  
    add(new Label("teamTwoName", teamList.get(1).getName()));
    add(new Label("scoreTwo", 
        matchesSession.getMatch(match.getName()).getTeamPoints(teamList.get(1)).toString()));

  }
  
}
